package lib

import (
	"bytes"
	"os/exec"
	"runtime"
	"strings"
	"syscall"
)

func execCmd(cmd string) {
	args := strings.Split(cmd," ")
	var c *exec.Cmd
	switch runtime.GOOS {
	case "darwin":

	case "windows":
		if len(args) > 1 {
			cmdArgs := args[1:]
			c = exec.Command(args[0],cmdArgs...)
		}else {
			c = exec.Command(args[0])
		}
		c.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
		break;
	case "linux":
		c = exec.Command("/bin/sh","-c",cmd)
		break;
	}

	var out bytes.Buffer
	c.Stdout = &out
	c.Run()
	//out,_ := c.Output()
	logger.Println(out.String())
}
